Skip to content

feat!: options and progress for cookbook transfers, and consistent option names - #152

Merged
tas50 merged 1 commit into
mainfrom
feat/cookbook-transfer-options
Nov 27, 2026
Merged

tas50 merged 1 commit into
mainfrom
feat/cookbook-transfer-options

Conversation

@tas50

@tas50 tas50 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Cookbooks.Download, DownloadFiles and CookbookArtifacts.Upload took no options. Adding a variadic parameter after 1.0 would break method values and interface satisfaction, so they get one now. The first options are progress reporting, which a CLI needs for a large cookbook:

  • WithUploadProgress(fn) for Cookbooks.Upload and CookbookArtifacts.Upload. It reports each file as it is uploaded. Files the server already holds are neither sent nor reported.
  • WithDownloadProgress(fn) for Download and DownloadFiles. It reports each file once it is in place, whether fetched or already present, so the reports add up to the manifest.

Transfers run in parallel, so fn may be called concurrently. This is documented.

CookbookArtifacts.Upload refuses WithFreeze and WithForce, because an artifact's identifier is a content hash and the server never replaces one.

Consistent names:

  • UploadOption → CookbookUploadOption, next to the new CookbookDownloadOption. Client.Upload and CookbookArtifacts.Upload are uploads too, so the bare name was ambiguous.
  • SkipChefignore → WithSkipChefignore, like every other option constructor.
  • OrgUser.PublicKey is removed. erchef only fills it at API version 0 (chef_user.erl), and the client speaks 1.

Breaking: the two renames, the removed field, and the new variadic parameters. The parameters break only code that stores the methods as values.

Test plan

  • New tests:
    • upload progress for cookbooks and artifacts reports only the files sent
    • download progress includes a file already present
    • artifact upload refuses freeze/force before sending
  • go test ./... -race -count=2; new code at 100% coverage
  • cd integration && go test ./..., golangci-lint in both modules

…tion names

Cookbooks.Download, DownloadFiles and CookbookArtifacts.Upload took no
options, and adding a variadic parameter after 1.0 would break method
values and interface satisfaction. They now take options, starting with
progress reporting a CLI needs for a large cookbook:

- WithUploadProgress (Cookbooks.Upload, CookbookArtifacts.Upload) reports
  each file as it is uploaded; files the server already holds are not
  sent and not reported.
- WithDownloadProgress (Download, DownloadFiles) reports each file once
  it is in place, fetched or already present, so the reports add up to
  the manifest.

CookbookArtifacts.Upload refuses WithFreeze and WithForce: an artifact's
identifier is a content hash and the server never replaces one.

UploadOption is CookbookUploadOption, beside the new
CookbookDownloadOption, since Client.Upload and CookbookArtifacts.Upload
are uploads too. SkipChefignore is WithSkipChefignore, like every other
option constructor. OrgUser.PublicKey is removed: erchef fills it only at
API version 0 (chef_user.erl), and the client speaks 1.

BREAKING CHANGE: UploadOption is CookbookUploadOption, SkipChefignore is
WithSkipChefignore, OrgUser.PublicKey is removed, and Download,
DownloadFiles and CookbookArtifacts.Upload take variadic options.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 merged commit 2ab3429 into main Nov 27, 2026
7 checks passed
@tas50
tas50 deleted the feat/cookbook-transfer-options branch November 27, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant